import { nodeAllocStatusOptions } from '@/enums/node'

export default function useConfig() {
  const { allRegionOptions } = useRegions()
  const columns = computed(() =>
    buildColumns([
      {
        title: '所属区域',
        dataIndex: 'region_name',
        width: 120,
        render({ record }) {
          return getOptionLabel(record.region_id, allRegionOptions.value)
        },
      },
      {
        title: 'IPMI地址',
        dataIndex: 'ipmi',
        minWidth: 130,
        format: 'copy',
      },
      {
        title: 'CPU型号',
        dataIndex: 'cpu',
        minWidth: 132,
      },
      {
        title: '内存',
        dataIndex: 'memory',
        width: 88,
        render({ record }) {
          return `${record.memory}G`
        },
      },
      {
        title: '硬盘',
        dataIndex: 'storage',
        minWidth: 96,
        render({ record }) {
          return `${record.storage}G`
        },
      },
      {
        title: '节点状态',
        dataIndex: 'status',
        minWidth: 96,
        slotName: 'status',
      },
      {
        title: '分配状态',
        dataIndex: 'alloc',
        minWidth: 80,
        render({ record }) {
          return getOptionLabel(record.alloc, nodeAllocStatusOptions)
        },
      },
      {
        title: '标签',
        dataIndex: 'tag',
        minWidth: 180,
        slotName: 'tag',
      },
      {
        title: '操作',
        fixed: 'right',
        slotName: 'actions',
        width: 90,
        cellClass: 'actions-cell',
      },
    ]),
  )
  return { columns }
}
